<%@ page language="java" pageEncoding="UTF-8"%>
<%@include file="/pc/jsp/common/common.jsp"%>
<%@ page language="java" import="com.limao.DBDataClass.SysProjectCateDataClass"%>
<%@ page language="java" import="com.limao.DBDataClass.CrowdSysProjectClass"%>
<%@ page language="java" import="com.limao.Model.PublicData"%>

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <title>商品详情</title>
    <script src="pc/js/jquery.touchSlider.js"></script>
    <!-- 	<script>
            $(window).load(function() {
                headertabcurrent=1;
                $("#header").load("pc/header.jsp");
                $("#footer").load("pc/footer.jsp");

                //headerTab(1);
            });
        </script> -->

</head>

<body  ontouchstart="">

 <a href="javascript:history.back();" class="db pf comeBackBtn">
    	<div class="w100 of cf tc cursor hblue" style="height:40px;line-height: 40px;margin-top:50px;">
	    		返回
	    </div>
</a>
<div class="container jz" style="width: 1220px;padding: 0 10px;">
    <p id="afterTittle" class="w100 c3 f20 mgt30">豆豆商城 > 商品详情</p>

</div><!--container-->


        <!--footer-->
        <div id="footer" class="footer w100 of"></div>


        <div id="loadingfDiv" class="loadingfDiv pf w100 h100 db">
            <div class="w100 h100">
                <img src="pc/images/loading.gif" class="db jz" style="margin-top: 40%;">
            </div>
        </div><!--loadinfDiv-->

        <script type="text/javascript">

            //获取url中的参数
            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
                var r = window.location.search.substr(1).match(reg);  //匹配目标参数
                if (r != null) return unescape(r[2]); return null; //返回参数值
            }
            var prestigeid = getUrlParam('prestigeid');


  
     // 加载新数据
    function getData(prestigeid) {
        $.ajax({
            url: "PlugServlet",
            data: JSON.stringify({m: 1678,prestigeid:prestigeid}),
            type: 'post',
            dataType: 'json',
            contentType: "application/json;charset=utf-8",
            beforeSend: function () {
            },
            success: function (data) {
 				
               if (data.state == 1) {
                   showData(data.obj); 
                } else {
                    // 其他错误弹出提示
                    alert(data.info);
                }
            },
            error: function (data) {
                alert(data.info);
            },
            complete: function () {
            }
        });
    }


            //插入数据
          function showData(obj){
            
           console.log(obj);
               var tmpimg = obj.prestigeimage.split(';');
                
                var introimage = obj.introimage.split(';');
                
                if(obj.prestigeintro == ""||obj.prestigeintro == undefined||obj.prestigeintro == null){
                    obj.prestigeintro = "暂无";
                };
                var imgList = "";
                var dotList = "";
                var imgDetailList = "";
                for (var i = 0; i < tmpimg.length; i++) {

                    imgList +='<li>'+
                                '<a href="javascript:void(0);"><img src="'+imgBaseUrl+tmpimg[i]+'" class="db w100 h100" ></a>'+
                              '</li>';
                    imgDetailList += '<img src="'+imgBaseUrl+introimage[i]+'" class="w100 hauto" style="margin-bottom: 7px;">'
                }
                console.log(imgList);
                for (var i = 0; i < tmpimg.length; i++) {
                    dotList += '<a href="#" class="">' + i +'</a>';
                }
                
                var kuCun = obj.limitenum - obj.buynum;
                if(kuCun <0 ){
                	kuCun = "出错";
                }else if(kuCun == 0){
                	kuCun = "暂无库存";
                }
                
               
				  var htmlStr = '<div class="proView bcf w100 mgt20 of clearfix">'+
					                '<div class="main_visual2 db fl pr">'+
					                    '<div class="flicking_con of">'+
					                        dotList+
					                    '</div>'+
					                    '<div class="main_image2">'+
					                        '<ul>'+
					                            imgList+
					                        '</ul>'+
					                        '<a href="javascript:;" id="btn_prev"></a>'+
					                        '<a href="javascript:;" id="btn_next"></a>'+
					                    '</div>'+
					                '</div>'+

					                '<div class="fr">'+
					                    '<p class="f22 c3 mgt10">'+obj.prestigename+'</p>'+
					                    '<div class="w100 dashLine" style="margin-top: 5px;margin-bottom: 5px;"></div>'+
					                    '<div class="w100 mgt10 clearfix of">'+
						                    '<p class="f16 c9 fl">库存：<span class="cred f25">'+kuCun+'</span></p>'+
						                    '<p class="fr tr f16 c9">购买次数：<span class="cblue f25">'+obj.buynum+'</span></p>'+
					                    '</div>'+
					                    '<p class="f17 fb c3 mgt18">商品简介</p>'+
					                    '<div class="w100 dashLine" style="margin-top: 8px;margin-bottom: 15px;"></div>'+
					                    '<div class="w100 clearfix of" style="height:125px;" >'+
					                        '<p class="f16 c9 t2 lh18">'+
												obj.prestigeintro+
					                        '</p>'+
					                    '</div>'+
					                    '<p class="f17 fb c3 mgt18">价格</p>'+
					                    '<div class="w100 dashLine" style="margin-top: 8px;margin-bottom: 15px;"></div>'+
					                   '<div class="w100 mgt10 clearfix of">'+
						                    '<p class="f16 c9 fl">狸猫豆：<span class="cred f25">'+obj.requirevalue+'</span></p>'+
						                    '<p class="fr tr f16 c9">市场价：<span class="cblue f25 lineThroughSpan">'+obj.oldprice+'</span></p>'+
					                    '</div>'+
					                    '<div class="w100 mgt10 clearfix of">'+
						                    '<p class="f16 c9 fl">回购价：<span class="cred f25">'+obj.callbackprice+'</span></p>'+
					                    '</div>'+
					                    '<div class="w100 dashLine" style="margin-top: 25px;margin-bottom: 7px;"></div>'+
					                    '<p class="f16 c9">分享到</p>'+
					                    '<div class="fenxiang mgt10 w100 clearfix of">'+
					                        '<span class="weibo"></span>'+
					                        '<span class="tengxunweibo"></span>'+
					                        '<span class="kongjian"></span>'+
					                        '<span class="douban"></span>'+
					                        '<span class="renren"></span>'+
					                        '<span class="weixin"></span>'+
					                    '</div>'+
					                '</div>'+
					            '</div>'+
					             '<div class="w100 clearfix of">'+
						                '<div class="proBlockLeft fl">'+
						                    '<div id="proDetailTab" class="proDetailTab bcf w100 clearfix of f22 c3 tc">'+
						                        '<div class="proDetailCurrent">图片简介</div>'+
						                    '</div><!--proDetailTab-->'+
						                    '<div id="proDetailTabDiv" class="proDetailTabDiv bcf of">'+
						                        '<div class="chanpinBlock" style="display: block">'+
						                            '<div class="of">'+
						                           		imgDetailList +
						                            '</div>'+
						                        '</div> <!--chanpinBlock-->'+
						                    '</div>'+
						                '</div> <!--proBlockLeft-->'+
						                  '<div class="proBlockRight fr">'+
						                    '<div class="zhichiProject bcf of">'+
						                        '<div class="clearfix of tittle">'+
						                            '<div class="fl cred">'+
						                                '<span class="f34" id="pgprice" >'+obj.requirevalue+'</span><span class="f25"></span><span class="c3 f16">(狸猫豆)</span>'+
						                            '</div>'+
						                            '<div class="fr c3 f16" style="margin-top: 8px;">'+obj.buynum+'&nbsp;&nbsp;购买次数</div>'+
						                        '</div>'+
						                        '<div class="zhichiProjectContent">'+
						                            '<p class="f17 fb c3 mgt18">规格</p>'+
						                            '<div class="w100 dashLine" style="margin-top: 8px;margin-bottom: 15px;"></div>'+
						                            '<div id="guiGe" class="payWay2 w100 clearfix of">'+
						                                '<div class="clearfix of w100">'+
						                                    '<div class="br3 fl payCurrent">无</div>'+
						                                '</div>'+
						                            '</div>'+
						
						                            '<p class="f17 fb c3 mgt30">数量</p>'+
						                            '<div class="w100 dashLine" style="margin-top: 8px;margin-bottom: 15px;"></div>'+
						                            '<div class="countDiv w100 clearfix of" style="margin-left:70px;">'+
						                                '<input id="minus" name="" type="button" value="-" style="font-size: 56px;"/>'+
						                                '<input id="count" name="" type="text" value="1" onkeyup="Numfunc()" onchange="toTotal();"  class="count br6 bcf fl"/>'+
						                                '<input id="add" name="" type="button" value="+" />'+
						                            '</div>'+
						                            '<div class="w100 dashLine" style="margin-top: 8px;margin-bottom: 15px;"></div>'+
						                            '<div class="zhichiProjectButton cf tc db jz cursor" onclick="javascript:buySth(prestigeid,$(\'#count\').val())">确定购买  消耗&nbsp;&nbsp;<span class="f16">豆豆</span><span class="f25" id="moneyChange">'+obj.requirevalue+'</span><span class="f15"></span></div>'+
						                            '<form id="buyForm" name="buyForm" method="post" action="PcWebPayServlet"></form>'+
						                        '</div> <!--zhichiProjectContent-->'+
						                    '</div> <!--zhichiProject-->'+
						                '</div><!--proBlockRight-->'+

						              
						          '</div>';
              


                $("#afterTittle").after(htmlStr);
                scollImg();
            }
            function Numfunc(){
            var t = $("#count").val();
				var patt1 = /^[1-9]\d*$/;
				if(!(t.match(patt1))||t==NaN||t==""){
					$("#count").val("1");
				}
				toTotal();
            }
            
            
            
             // 购买
			    function buySth(prestigeid,num) {
			        $.ajax({
			            url: "PlugServlet",
			            data: JSON.stringify({m: 1672,prestigeid:prestigeid,num:num}),
			            type: 'post',
			            dataType: 'json',
			            contentType: "application/json;charset=utf-8",
			            beforeSend: function () {
			
			            },
			            success: function (data) {
			 				console.log(data);
			               if (data.state == 1) {
			                  // 成功弹出提示
			                  alert(data.info);
			                } else {
			                    // 其他错误弹出提示
			                    alert(data.info);
			                }
			            },
			            error: function (data) {
			                alert(data.info);
			            },
			            complete: function () {
			                closeProgressDg();
			                window.location.reload();  
			            }
			        });
			    }

            function scollImg(){
                //            图片滑动
                $(".main_visual2").hover(function(){
                    $("#btn_prev,#btn_next").fadeIn()
                },function(){
                    $("#btn_prev,#btn_next").fadeOut()
                });

                $dragBln = false;

                $(".main_image2").touchSlider({
                    flexible : true,
                    speed : 1000,
                    btn_prev : $("#btn_prev"),
                    btn_next : $("#btn_next"),
                    paging : $(".flicking_con a"),
                    counter : function (e){
                        $(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");
                    }
                });

                $(".main_image2").bind("mousedown", function() {
                    $dragBln = false;
                });

                $(".main_image2").bind("dragstart", function() {
                    $dragBln = true;
                });

                $(".main_image a").click(function(){
                    if($dragBln) {
                        return false;
                    }
                });

                timer = setInterval(function(){
                    $("#btn_next").click();
                }, 3500);

                $(".main_visual").hover(function(){
                    clearInterval(timer);
                },function(){
                    timer = setInterval(function(){
                        $("#btn_next").click();
                    },3500);
                });

                $(".main_image2").bind("touchstart",function(){
                    clearInterval(timer);
                }).bind("touchend", function(){
                    timer = setInterval(function(){
                        $("#btn_next").click();
                    }, 3500);
                });
                
                
                
                $("#guiGe>div>div").bind('click',function () {
                    $("#guiGe>div>div").removeClass('payCurrent');
                    $(this).addClass('payCurrent');
                    selectextraVal = $('#guiGe .payCurrent').text();
                })

                //获得文本框对象
                var t = $("#count");

                //数量增加操作
                $("#add").click(function(){
                    t.val(parseInt(t.val())+1);
                    toTotal();
                })
                //数量减少操作
                $("#minus").click(function(){
                    if (parseInt(t.val())==1){
                        return ;
                    }
                    t.val(parseInt(t.val())-1);
                    toTotal();
                })
            }




            $(function(){
				
				getData(prestigeid);

            });
            /* var projectidV=1;
             var curpageForBuyUser=1;
             var taotalPagesForBuyUser=1;

             var curpageForChat=1;
             var taotalPagesForChat=1;
             */
/*             $().ready(function() {
                //loadBuyUserList(1);
                // loadChatList(1);
            }); */


            var paywayVal=0;

            var selectextraVal="";



            function toTotal()
            {

                $("#moneyChange").html($.trim($("#count").val())*1.0*$.trim($("#pgprice").html()));

            }

            function Sub(projectidV) {

                var numVal= parseInt($.trim($("#count").val()));
                if(numVal<=0)
                {
                    layer.alert("数量不正确。");
                    return;
                }

                location.href="pc/myAddress.jsp?projectid="+projectidV+"&num="+numVal+"&selectextra="+selectextraVal;

                /*
                 console.log(paywayVal);
                 if(paywayVal<2)
                 {
                 layer.alert("暂不支持，请选择  银联支付 或 余额支付  进行测试。");
                 return;
                 }

                 if(paywayVal==10)
                 {
                 var contentHtml='';
                 contentHtml=contentHtml+'<input type="hidden" name="projectid" id="projectid" value="'+projectidV+'"/>'+
                 '<input type="hidden" name="selectextra" id="selectextra" value="'+selectextraVal+'"/>'+
                 '<input type="hidden" name="num" id="num" value="'+numVal+'"/>'+
                 '<input type="hidden" name="about" id="about" value=""/>'+
                 '<input type="hidden" name="paytype" id="paytype" value="'+paywayVal+'"/>';
                 $("#buyForm").html(contentHtml);
                 document.buyForm.submit();
                 }
                 else
                 {
                 if(paywayVal*1.0==2)
                 {
                 var tempwindow=window.open();
                 }

                 $.ajax({
                 url: "PlugServlet ",
                 data: JSON.stringify({m:1720,projectid :projectidV,selectextra:selectextraVal,num:numVal,about:'',paytype:paywayVal,apptype:0}),
                 type: 'post',
                 dataType: 'json',
                 contentType:"application/json;charset=utf-8",
                 beforeSend: function () {
                 $("#loadingfDiv").fadeIn();
                 },
                 success: function (data) {

                 console.log(data);
                 if(data['state']==1)
                 {
                 //layer.alert(data.info);
                 if(data['paytype']*1.0==2)
                 {
                 console.log(baseUrl+'pc/unionProPay.jsp?orderid='+data['orderid']);
                 tempwindow.location=baseUrl+'pc/unionProPay.jsp?orderid='+data['orderid'] ;
                 }
                 else
                 {
                 layer.alert(data.info);
                 }
                 }
                 else
                 {
                 layer.alert(data.info);
                 }
                 },
                 error: function (data) {
                 layer.alert(data.msg);
                 return false;
                 },
                 complete: function () {
                 $("#loadingfDiv").fadeOut();
                 }
                 });
                 }

                 */


            }




            //            IE圆角,必须放到最下面！所有js之后！
            if (window.PIE) {
                $('.rounded,.flicking_con a,.proSection .bar_span,.proSection .progress,.blueBtn,.yuanjiao,.br3,.br6').each(function() {
                    PIE.attach(this);
                });
            }

        </script>
</body>

</html>